// import { message } from "@/utils/message";
import { transformI18n } from "@/plugins/i18n";
import { addDialog } from "@/components/ReDialog";
import {
  getHomeData,
  getAcquisitionData,
  addDeviceData,
  deleteDeviceData,
  updateDeviceData,
  deleteVariableData,
  updateVariableData,
  addVariableData,
  copyDeviceData,
  updateDeviceDataList
} from "@/api/edgeAcquisition";
import type { Tree } from "./type";
import { reactive, ref, onMounted, toRaw, h } from "vue";
import { message } from "@/utils/message";

import addDeviceForm, { type deviceFormProps } from "./add_device_form.vue";
import writeValueForm, { type writeValueProps } from "./write_value_form.vue";
import addVariablesForm, {
  type variablesFormProps
} from "./add_variables_form.vue";
import copy_forms, { type copyFormProps } from "./copy_device_form.vue";
import update_forms, { type updateFormProps } from "./update_device_form.vue";
import { ElMessageBox } from "element-plus";
export function useRole() {
  const editMap = ref({});
  const type_Bool_select_option = [{ label: "Bool", value: "Bool" }];
  const type_usually_select_option = [
    { label: "Int16", value: "Int16" },
    { label: "Uint16", value: "Uint16" },
    { label: "Int32", value: "Int32" },
    { label: "Uint32", value: "Uint32" },
    { label: "Int64", value: "Int64" },
    { label: "Uint64", value: "Uint64" },
    { label: "Float", value: "Float" },
    { label: "Double", value: "Double" },
    { label: "SBCD16", value: "SBCD16" },
    { label: "BCD16", value: "BCD16" },
    { label: "SBCD32", value: "SBCD32" },
    { label: "BCD32", value: "BCD32" },
    { label: "SBCD64", value: "SBCD64" },
    { label: "BCD64", value: "BCD64" },
    { label: "U16_00", value: "U16_00" },
    { label: "U16_01", value: "U16_01" },
    { label: "U16_02", value: "U16_02" },
    { label: "U16_03", value: "U16_03" },
    { label: "U16_04", value: "U16_04" },
    { label: "U16_05", value: "U16_05" },
    { label: "U16_06", value: "U16_06" },
    { label: "U16_07", value: "U16_07" },
    { label: "U16_08", value: "U16_08" },
    { label: "U16_09", value: "U16_09" },
    { label: "U16_10", value: "U16_10" },
    { label: "U16_11", value: "U16_11" },
    { label: "U16_12", value: "U16_12" },
    { label: "U16_13", value: "U16_13" },
    { label: "U16_14", value: "U16_14" },
    { label: "U16_15", value: "U16_15" },
    { label: "HEX", value: "HEX" },
    { label: "Str", value: "Str" }
  ];
  const property_select_option = [
    { label: "读写", value: 0 },
    { label: "只写", value: 1 }
  ];
  const form = reactive({
    customerName: "",
    shortName: "",
    mobile: "",
    remark: ""
  });

  const isShow = ref(false);
  const loading = ref(false);

  const isOpen = ref(false);
  var columns = ref([]);
  // 首页的那个数据
  const homeData = ref();
  const product = ref();
  const deviceInfo = ref();
  const interfaces = ref();

  const ws = ref<WebSocket | null>(null); // 已定义
  // 边缘采集的数据
  const acquisitionData = ref();
  // CRC顺序数据
  const crcModeData = ref([
    { label: "LH", value: 0 },
    { label: "HL", value: 1 }
  ]);
  // 4 区 16 位写功能 数据
  const write16CmdData = ref([
    { label: "0X06", value: 0 },
    { label: "0X10", value: 1 }
  ]);
  // 16位整数解码
  const int16OrderData = ref([
    { label: "AB", value: 0 },
    { label: "BA", value: 1 }
  ]);
  // 32位整数解码
  const int32OrderData = ref([
    { label: "AB", value: 0 },
    { label: "BA", value: 1 }
  ]);
  // 浮点32位解码
  const floatOrderData = ref([
    { label: "ABCD", value: 0 },
    { label: "CDAB", value: 1 },
    { label: "BADC", value: 2 },
    { label: "DCBA", value: 3 }
  ]);
  // 整数64位解码
  const int64OrderData = ref([
    { label: "ABCDEFGH", value: 0 },
    { label: "GHEFCDAB", value: 1 },
    { label: "BADCFEHG", value: 2 },
    { label: "HGFEDCBA", value: 3 }
  ]);
  // 浮点64位解码
  const doubleOrderData = ref([
    { label: "ABCDEFGH", value: 0 },
    { label: "GHEFCDAB", value: 1 },
    { label: "BADCFEHG", value: 2 },
    { label: "HGFEDCBA", value: 3 }
  ]);
  // ASCii 解码
  const asciiOrderData = ref([
    { label: "AB", value: 0 },
    { label: "BA", value: 1 }
  ]);
  // 工作模式
  const workModeData = ref([
    { label: "边缘采集", value: 0 },
    { label: "透传", value: 1 }
  ]);
  // 新增设备的时候  通讯接口下拉的数据  (所有接口的总和)
  const allSelectOption = ref([]);
  // 第二列所属接口串口的下拉数据
  const interfaceSeleteOption = ref([]);
  // 串口时候 下拉的数据
  const serialPortSelectlist = ref([]);
  // 网口时候下拉的数据
  const networkInterfaceSelectList = ref([]);
  // 默认选中的设备
  const selected_by_default_id = ref(0);
  // 所有设备、变量的数据
  // 左边树的数据
  const tree_data = ref<Tree[]>([]);
  // 调试值临时的储存
  const realTimeData = ref([]);
  // 当前选中的设备的信息储存
  const current_device_data = ref({
    interfaceName: "",
    remoteIp: "",
    remotePort: 0,
    id: 0,
    subDeviceId: "",
    pollCycle: 0,
    pollInterval: 0,
    responseTimeout: 0,
    maxLength: 0,
    discontinuousAddressInterval: 0,
    crcMode: 0,
    write16Cmd: 0,
    int16Order: 0,
    int32Order: 0,
    floatOrder: 0,
    int64Order: 0,
    doubleOrder: 0,
    asciiOrder: 0,
    keepValue: 0,
    protocol: "",
    workMode: 0,
    variables: []
  });
  // 创建树形结构数据
  const createTreeStructure = (data: any[]): Tree[] => {
    const tree: Tree[] = [];
    let deviceCounter = 1; // 全局计数器，用于所有子设备的编号
    data.forEach(item => {
      // 查找是否已经存在顶层节点
      let parentNode = tree.find(node => node.label === item.interfaceName);
      if (!parentNode) {
        // 如果不存在，则创建新的父节点
        parentNode = {
          label: item.interfaceName,
          id: 0,
          children: []
        };
        tree.push(parentNode);
      }
      // const currentDeviceCount = parentNode.children
      //   ? parentNode.children.length + 1
      //   : 1; // +1 为了顺序编号从 1 开始
      // 添加子节点
      const childNode: Tree = {
        label: `设备 ${deviceCounter}: ${item.subDeviceId}:${item.subDeviceNum}`,
        id: item.id
      };
      deviceCounter++; // 增加全局计数器
      parentNode.children?.push(childNode);
    });

    return tree;
  };
  // 只是拿到数据,不弄树结构  也不默认点击第一个
  async function searchAcquisitionData1() {
    try {
      const result = await getAcquisitionData();
      acquisitionData.value = result;
    } catch (error) {
      console.log(error);
    }
  }

  // 查出来全部设备/变量的数据
  async function searchAcquisitionData() {
    try {
      const result = await getAcquisitionData();

      acquisitionData.value = result;
      // 拿到树的结构
      tree_data.value = createTreeStructure(acquisitionData.value);
      if (tree_data.value.length > 0 && tree_data.value[0].children) {
        selected_by_default_id.value = tree_data.value[0].children[0].id; // 获取第一个子节点的 ID
        current_device_data.value = findItemById(selected_by_default_id.value);

        // 在这判断默认选中的 interfaceName  属于哪个接口
        const interfaceName = current_device_data.value.interfaceName;
        if (interfaceName.includes("Ethernet")) {
          interfaceSeleteOption.value = networkInterfaceSelectList.value;
        } else {
          interfaceSeleteOption.value = serialPortSelectlist.value;
        }
      } else {
        console.warn("树数据为空或不包含子节点");
      }
    } catch (error) {
      console.error("树数据处理时出错：", error);
    }
  }
  // 拿到第二列所属接口第一列下拉所需要的所有的数据
  function getInterfaceSelectOptions() {
    // 初始化需要返回的列表
    serialPortSelectlist.value = [];
    networkInterfaceSelectList.value = [];

    // 定义要处理的设备类型及其目标列表
    const mappings = {
      COM: serialPortSelectlist,
      LoRa: serialPortSelectlist,
      Ethernet: networkInterfaceSelectList
    };

    // 遍历设备类型，生成对应的选项
    for (const key in mappings) {
      const count = interfaces.value[key];

      for (let i = 1; i <= count; i++) {
        const item = {
          label: `${key}${i}`, // e.g., 'COM1', 'Ethernet1'
          value: `${key}${i}` // e.g., 'COM1', 'Ethernet1'
        };
        mappings[key].value.push(item); // 将项推入相应的列表
      }
    }
    allSelectOption.value = [
      ...networkInterfaceSelectList.value,
      ...serialPortSelectlist.value
    ];
  }

  // 点击设备  获取选中设备的数据
  const findItemById = (id: number) => {
    const data = toRaw(acquisitionData.value); // 获取 ref 的值

    // 假设 acquisitionData 是一个数组，直接使用 find 方法
    const item = data.find((item: any) => item.id === id);

    return item || null; // 如果找到则返回该项，否则返回 null
  };

  // 拿首页所有的数据
  async function onSearch() {
    loading.value = true;
    setTimeout(() => {
      loading.value = false;
    }, 500);
    const { data } = await getHomeData();
    homeData.value = data;
    product.value = data.product;
    deviceInfo.value = data.deviceInfo;
    interfaces.value = data.interfaces;
  }
  // 点击左侧树
  const handleNodeClick = (data: Tree) => {
    // 判断点树枝不点树干
    if (!data.children) {
      if (isOpen.value) {
        closeDebug();
      }
      current_device_data.value = findItemById(data.id);
      // console.log("ooooo", current_device_data.value);
      // 在这判断默认选中的 interfaceName  属于哪个接口
      const interfaceName = current_device_data.value.interfaceName;
      if (interfaceName.includes("Ethernet")) {
        interfaceSeleteOption.value = networkInterfaceSelectList.value;
      } else if (
        interfaceName.includes("COM") ||
        interfaceName.includes("LoRa")
      ) {
        interfaceSeleteOption.value = serialPortSelectlist.value;
      }
    }
  };

  // 新增设备按钮
  function clickAddDevice() {
    addDialog({
      width: "30%",
      title: "添加子设备",
      closeOnClickModal: false,
      draggable: true,
      // contentRenderer: () => addDeviceForm,
      props: {
        // 赋默认值
        formInline: {
          allSelectOption: allSelectOption,
          interfaceName: "", // 通讯接口
          type: "", //类别
          protocol: "", //通讯协议
          subDeviceNum: "", //子设备站号
          subDeviceId: "" //子设备ID
        }
      },

      contentRenderer: () => h(addDeviceForm),
      beforeSure: (done, { options }) => {
        const { formInline } = options.props as deviceFormProps;
        async function chores() {
          done();
        }
        // eslint-disable-next-line @typescript-eslint/no-unused-vars
        const { allSelectOption, ...newObject } = formInline;
        addDeviceData([newObject]).then(res => {
          // 新增完  重新生成树
          if (res.status === 5005) {
            message("子设备名不能重复", { type: "error" });
            return;
          }
          chores();
          searchAcquisitionData();
        });
      }
    });
  }

  // 点击后面的复制该设备
  const copyDevice = (data: Tree) => {
    // console.log("赋值得到的data", data);
    addDialog({
      width: "30%",
      title: `复制子设备  [${data.label}]`,
      closeOnClickModal: false,
      // contentRenderer: () => copy_forms,
      props: {
        // 赋默认值
        formInline: {
          id: Number(data.id),
          subDeviceNum: "", //子设备站号
          subDeviceId: "" //子设备ID
        }
      },

      contentRenderer: () => h(copy_forms),
      beforeSure: (done, { options }) => {
        const { formInline } = options.props as copyFormProps;
        async function chores() {
          done();
        }
        copyDeviceData([formInline]).then(res => {
          if (res.status === 5005) {
            message("设备id不能重复", { type: "error" });
            return;
          }
          chores();
          searchAcquisitionData();
          message("复制成功", { type: "success" });
        });
      }
    });
  };

  //点击后面的修改设备 信息
  const updateDevice = (data: Tree) => {
    const matchResult = toRaw(data.label).match(/:(.*?):(.*)/);
    const a = matchResult[1].trim();
    const b = matchResult[2].trim();
    addDialog({
      width: "30%",
      title: `修改子设备  [${data.label}]`,
      closeOnClickModal: false,
      // contentRenderer: () => update_forms,
      props: {
        // 赋默认值
        formInline: {
          id: Number(data.id),
          subDeviceId: a,
          subDeviceNum: b
        }
      },
      contentRenderer: () => h(update_forms),
      beforeSure: (done, { options }) => {
        const { formInline } = options.props as updateFormProps;
        async function chores() {
          done();
        }
        updateDeviceDataList([formInline]).then(res => {
          if (res.status === 5005) {
            message("设备id不能重复", { type: "error" });
            return;
          }
          chores();
          searchAcquisitionData();
          message("修改成功", { type: "success" });
        });
      }
    });
  };

  // 点击后面的删除该设备
  const deleteDevice = (node: any, data: Tree) => {
    ElMessageBox.confirm(`确认删除?`, "提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning"
    })
      .then(() => {
        //删除处理确认操作
        message("删除成功", { type: "success" });
        deleteDeviceData([data.id]).then(() => {
          searchAcquisitionData();
        });
      })
      .catch(() => {
        // 取消操作
      });
  };
  // 确认修改设备的配置
  function applyVariableChange() {
    // 修改完成之后  再重新查询一次数据
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    const { variables, ...newObject } = current_device_data.value;
    newObject.pollCycle = Number(newObject.pollCycle);
    newObject.pollInterval = Number(newObject.pollInterval);
    newObject.responseTimeout = Number(newObject.responseTimeout);
    if (newObject.remotePort) {
      newObject.remotePort = Number(newObject.remotePort);
    }

    // console.log("newObject", newObject);

    updateDeviceData([newObject]).then(() => {
      message("修改成功", { type: "success" });
      searchAcquisitionData1();
    });
  }

  // 添加变量   的按钮
  const addVariable = () => {
    addDialog({
      width: "30%",
      title: "添加变量",
      closeOnClickModal: false,
      draggable: true,
      // contentRenderer: () => addVariablesForm,
      props: {
        // 赋默认值
        formInline: {
          acquisitionId: current_device_data.value.id,
          region: "", // 通道
          type: "", //类别
          newAddress: 0, //寄存器地址
          num: 1 //数量
        }
      },

      contentRenderer: () => h(addVariablesForm),
      beforeSure: (done, { options }) => {
        const { formInline } = options.props as variablesFormProps;
        async function chores() {
          done();
        }
        // const { allSelectOption, ...newObject } = formInline;
        formInline.num = Number(formInline.num);
        formInline.newAddress = Number(formInline.newAddress);
        addVariableData([formInline]).then(res => {
          if (res.status === 5005) {
            message("寄存器地址不能重复", { type: "error" });
            return;
          }
          chores();
          searchAcquisitionData1().then(() => {
            current_device_data.value = findItemById(
              current_device_data.value.id
            );
          });
        });
      }
    });
  };
  // 保存变量的时候
  function onSave(index) {
    updateVariableData([
      toRaw(current_device_data.value.variables[index])
    ]).then(res => {
      if (res.status == 5005) {
        message("地址或键名不能重复", { type: "error" });
        return;
      }
      editMap.value[index].editable = false;
    });
  }

  // 修改时点击取消的时候
  function onCancel(index) {
    editMap.value[index].editable = false;
    searchAcquisitionData1().then(() => {
      current_device_data.value = findItemById(current_device_data.value.id);
      if (!isOpen) {
        // openDebug();
        // current_device_data.value.variables.forEach((item, index) => {
        //   item.realTimeDataInfo = realTimeData.value[index] ?? "bad"; // 没对应则null或其它默认值
        // });
      }
    });
  }

  // 点击变量后面的删除
  function deleteVariable(row) {
    deleteVariableData([row.id]).then(() => {
      searchAcquisitionData1().then(() => {
        current_device_data.value = findItemById(row.acquisitionId);
        if (!isOpen) {
          // openDebug();
          // sendMessage();
          // current_device_data.value.variables.forEach((item, index) => {
          //   item.realTimeDataInfo = realTimeData.value[index] ?? "bad"; // 没对应则null或其它默认值
          // });
        }
      });
    });
  }

  const timerId = ref<number | null>(null);
  // 打开调试
  async function openDebug() {
    isOpen.value = !isOpen.value;

    const newObj = {
      label: "值",
      prop: "realTimeDataInfo",
      minWidth: 60,
      cellRenderer: scope => {
        const text =
          scope.row.realTimeDataInfo !== ""
            ? scope.row.realTimeDataInfo
            : "bad";
        const color = scope.row.realTimeDataInfo !== "bad" ? "green" : "red";
        return h("span", { style: `color: ${color}` }, text);
      }
    };

    columns.value.splice(1, 0, newObj);
    clearTimer();
    // 如果已连接，直接发送消息
    if (ws.value && ws.value.readyState === WebSocket.OPEN) {
      console.log("WebSocket 已连接，直接发送消息");
      // setInterval(() => {
      //   sendMessage();
      // }, 1000);
      timerId.value = window.setInterval(() => sendMessage(), 1000);
      return;
    }

    // 如果未连接或已关闭，创建新连接
    if (!ws.value || ws.value.readyState === WebSocket.CLOSED) {
      ws.value = new WebSocket(`ws://${window.location.hostname}:8082`, "ws");
      // ws.value = new WebSocket("ws://192.168.0.101:8082", "ws");

      ws.value.onopen = () => {
        console.log("WebSocket 连接已建立");
        // setInterval(() => {
        //   sendMessage();
        // }, 1000);
        timerId.value = window.setInterval(() => sendMessage(), 1000);
      };

      ws.value.onmessage = event => {
        const data = JSON.parse(event.data);
        // console.log("data66666", data.commandPar.realTimeDataInfo);
        // console.log("当前变量数据", current_device_data.value.variables);
        // TODO: 可以在这里处理返回数据
        if (data.commandPar) {
          realTimeData.value = Object.values(data.commandPar.realTimeDataInfo);
          current_device_data.value.variables.forEach((item, index) => {
            item.realTimeDataInfo = realTimeData.value[index] ?? "bad"; // 没对应则null或其它默认值
          });
        } else {
          // current_device_data.value.variables.forEach((item, index) => {
          //   item.realTimeDataInfo =
          //     data.commandPar.realTimeDataInfo[index] ?? "bad"; // 没对应则null或其它默认值
          // });
        }
      };

      ws.value.onclose = () => {
        console.log("WebSocket 连接已关闭");
        ws.value = null;
        clearTimer();
      };

      ws.value.onerror = error => {
        console.error("WebSocket 错误:", error);
        ws.value?.close();
        ws.value = null;
        clearTimer();
      };
    }
  }
  function clearTimer() {
    if (timerId.value !== null) {
      clearInterval(timerId.value);
      timerId.value = null;
    }
  }
  // 关闭长连接
  function closeDebug() {
    isOpen.value = !isOpen.value;
    columns.value.splice(1, 1);
    clearTimer();
    if (ws.value && ws.value.readyState === WebSocket.OPEN) {
      ws.value.close();
    } else if (ws.value && ws.value.readyState === WebSocket.CONNECTING) {
      ws.value.onopen = null; // 防止连接成功后继续执行
      ws.value.close();
      console.log("正在连接中的 WebSocket 已取消");
    }
  }
  // 发送长连接消息
  function sendMessage() {
    if (ws.value && ws.value.readyState === WebSocket.OPEN) {
      const message = JSON.stringify({
        messageId: Date.now().toString(),
        command: "readRealTimeData",
        commandPar: {
          realTimeDataType: "acquisition",
          realTimeDataId: current_device_data.value.subDeviceId
        }
      });
      ws.value.send(message);
      // console.log("消息已发送:", message);
    } else {
      console.warn("无法发送消息：WebSocket 未连接");
    }
  }
  // 点击单元格
  function cellDialogUpdate(row, column) {
    console.log("cellDialogUpdate", row, column);
    if (isOpen.value && column.id == "el-table_1_column_2") {
      // 在这里打开弹框 ,然后判断后显色弹框信息
      const setTitle = "写入测试";

      addDialog({
        width: "30%",
        title: setTitle,
        closeOnClickModal: false,
        draggable: true,
        props: {
          // 赋默认值
          formInline: {
            dataPointName: row.key,
            dataPointValue: row.realTimeDataInfo
          }
        },
        contentRenderer: () => h(writeValueForm),
        beforeSure: (done, { options }) => {
          const { formInline } = options.props as writeValueProps;
          async function chores() {
            done();
          }
          // eslint-disable-next-line @typescript-eslint/no-unused-vars
          const { ...newObject } = formInline;
          // console.log("确定之后的数据", newObject);
          const message1 = JSON.stringify({
            messageId: Date.now().toString(),
            command: "writeRealTimeData",
            commandPar: {
              realTimeDataType: "acquisition",
              realTimeDataId: current_device_data.value.subDeviceId,
              realTimeDataInfo: {
                [newObject.dataPointName]: newObject.newPointValue
              }
            }
          });
          ws.value.send(message1);
          // console.log("消息已发送:", message1);

          // issuedValueData([newObject]).then(res => {
          // 新增完  重新生成树
          chores();
          // searchAcquisitionData();
          // });
        }
      });
    }
  }
  const resetForm = formEl => {
    if (!formEl) return;
    formEl.resetFields();
    onSearch();
  };

  const filterMethod = (query: string, node) => {
    return transformI18n(node.title)!.includes(query);
  };

  const indexMethod = (index: number) => {
    return index + 1;
  };
  // 变量列表的数据
  columns.value = [
    {
      type: "index",
      label: "序号",
      minWidth: 70,
      align: "center",
      index: indexMethod
    },
    {
      label: "地址",
      prop: "address",
      cellRenderer: ({ row, index }) => (
        <>
          {editMap.value[index]?.editable ? (
            <el-input v-model={row.address} />
          ) : (
            <p>{row.address}</p>
          )}
        </>
      )
    },
    {
      label: "键名(标识)",
      prop: "key",
      cellRenderer: ({ row, index }) => (
        <>
          {editMap.value[index]?.editable ? (
            <el-input v-model={row.key} />
          ) : (
            <p>{row.key}</p>
          )}
        </>
      )
    },
    {
      label: "数据类型",
      prop: "type",
      cellRenderer: ({ row, index }) => (
        <>
          {editMap.value[index]?.editable ? (
            <el-select v-model={row.type} placeholder="请选择类型">
              {/* 根据 row.type 判断使用哪个选项 */}
              {(row.type === "Bool"
                ? type_Bool_select_option
                : type_usually_select_option
              ).map(item => {
                return (
                  <el-option
                    key={item.value}
                    label={item.label}
                    value={item.value}
                  />
                );
              })}
            </el-select>
          ) : (
            <div>
              {
                (row.type === "Bool"
                  ? type_Bool_select_option
                  : type_usually_select_option
                ).filter(opt => opt.value === row.type)[0]?.label
              }
            </div>
          )}
        </>
      )
    },
    {
      label: "属性",
      prop: "property",
      cellRenderer: ({ row, index }) => (
        <>
          {editMap.value[index]?.editable ? (
            <el-select v-model={row.property} placeholder="请选择属性">
              {property_select_option.map(item => {
                return (
                  <el-option
                    key={item.value}
                    label={item.label}
                    value={item.value} // 确保这里的 item.value 是数字
                  />
                );
              })}
            </el-select>
          ) : (
            <div>
              {
                property_select_option.filter(
                  opt => opt.value === row.property // 使用严格相等来进行比较
                )[0]?.label
              }
            </div>
          )}
        </>
      )
    },

    {
      label: "操作",
      fixed: "right",
      align: "center",
      minWidth: 100,
      slot: "operation"
    }
  ];

  function onEdit(row, index) {
    editMap.value[index] = Object.assign({ ...row, editable: true });
  }

  onMounted(async () => {
    onSearch();
    // searchAcquisitionData();
  });

  return {
    form,
    isShow,
    loading,
    onSearch,
    resetForm,
    filterMethod,
    transformI18n,
    homeData,
    product,
    deviceInfo,
    interfaces,
    acquisitionData,
    crcModeData,
    write16CmdData,
    int16OrderData,
    int32OrderData,
    floatOrderData,
    int64OrderData,
    doubleOrderData,
    asciiOrderData,
    workModeData,
    columns,
    editMap,
    onEdit,
    openDebug,
    closeDebug,
    cellDialogUpdate,
    isOpen,
    current_device_data,
    tree_data,
    copyDevice,
    getInterfaceSelectOptions,
    handleNodeClick,
    selected_by_default_id,
    applyVariableChange,
    updateDevice,
    deleteDevice,
    addVariable,
    searchAcquisitionData,
    updateVariableData,
    clickAddDevice,
    searchAcquisitionData1,
    findItemById,
    deleteVariable,
    interfaceSeleteOption,
    onSave,
    onCancel
  };
}
